// eslint-disable-next-line import/no-cycle,import/no-named-as-default,import/no-named-as-default-member
import BaseModule from './app/base-module'

const NavigationEvent = {
  popWebView() {
    return new Promise((resolve, reject) => {
      BaseModule.fireEventForAsync('popWebView')
        .then(() => {
          return resolve()
        })
        .catch((error) => {
          // TODO 全局提示
          return reject(error)
        })
    })
  },

  popWebViewToRoot() {
    return new Promise((resolve, reject) => {
      BaseModule.fireEventForAsync('popToRoot')
        .then(() => {
          return resolve()
        })
        .catch((error) => {
          // TODO 全局提示
          return reject(error)
        })
    })
  }
}

export default NavigationEvent;
